/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controllers;

import controllers.util.JsfUtil;
import generated_entities.Rates;
import java.util.ResourceBundle;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import rates_analysis.RatesAnalyzerSessionBeanLocal;

/**
 *
 * @author aav
 */
@ManagedBean
@RequestScoped
public class IndexController {
    @EJB
    private RatesAnalyzerSessionBeanLocal ratesAnalyzerSessionBean;

    /**
     * Creates a new instance of IndexController
     */
    public IndexController() {
    }
    
    public String updateRates() {
        try {
            if (0 < ratesAnalyzerSessionBean.updateRates()) {
                JsfUtil.addErrorMessage(ResourceBundle.getBundle("/Bundle").getString("RatesUpdateErrorOccured"));
            } else {
                JsfUtil.addSuccessMessage(ResourceBundle.getBundle("/Bundle").getString("RatesUpdated"));
            }
            return null;
        } catch (Exception e) {
            JsfUtil.addErrorMessage(e, ResourceBundle.getBundle("/Bundle").getString("RatesUpdateErrorOccured"));
            return null;
        }
    }
}
